import 'package:flutter/material.dart';
///
/// custom_scroll_view.dart
/// 视差滚动 示例
/// 没想到用flutter实现视差滚动这么简单
///

void main() => runApp(const MaterialApp(home: CustomScrollViewDemoWidget(),));

class CustomScrollViewDemoWidget extends StatelessWidget {
  const CustomScrollViewDemoWidget({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    final result = Scaffold(
      appBar: AppBar(title: const Text('视差滚动示例')),
      body: CustomScrollView(
        slivers: [
          SliverAppBar(
            title: const Text('CustomScrollView Demo'),
            floating: true,
            flexibleSpace: Image.network(
              'https://pic1.zhimg.com/v2-bff3b5129eb62501d05b73e24b593f49_r.jpg?source=172ae18b',
              fit: BoxFit.cover,
            ),
            expandedHeight: 220,
          ),
          SliverList(
            delegate: SliverChildBuilderDelegate(
              childCount: 100,
              (context, index) {
                return ListTile(title: Text('Item $index'),);
              }
            ),
          )
        ],
      ),
    );
    return result;
  }
}



